package Text38;

import java.util.*;

public class Main {
    static int[] month = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int t1 = in.nextInt();
        int t2 = in.nextInt();
        int date1 = t1 / 10000;
        int date2 = t2 / 10000;
        int res = 0;
        for (int i = date1; i <= date2; i++) {
            int date = i, x = i;
            while (x > 0) {
                date = date * 10 + x % 10;
                x /= 10;
            }
            if (date >= t1 && date <= t2 && check(date)) {
                res++;
            }
        }
        System.out.println(res);

    }

    private static boolean check(int date) {
        int y = date / 10000;
        int m = date % 10000 / 100;
        int d = date % 100;
        if(m==0||m>12){
            return false;
        }
        if(d==0||d>get_month_days(y,m)){
            return false;
        }
        return true;
    }

    private static int is_leap(int y) {
        if (y % 400 == 0 || y % 4 == 0 && y % 100 != 0) {
            return 1;
        }
        return 0;
    }

    private static int get_month_days(int y, int m) {
        if (m == 2) {
            return month[m] + is_leap(y);
        }
        return month[m];
    }
}
